home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 441 / sc_desk / batchmon / batchdoc.txt next >
Text File  |  1990-11-23  |  19KB  |  372 lines

  1.                              BATCHMON v2.1
  2.                         The simple batch monitor
  3.                                    by
  4.                   Ian "I didn't really do this" Lepore
  5.  
  6. -----------------------------------------------------------------------
  7.                              Release Notes
  8. -----------------------------------------------------------------------
  9.  
  10. Version 2.1 added the following new features:
  11.  
  12.      - Support for environment strings.
  13.      - The ability to change the default and exe paths.
  14.      - It  can be compiled with a  vanilla Sozobon  C  setup.   Anything   
  15.        using  my custom  libraries  has been  converted  to  the   dLibs   
  16.        functions, or has been included in source form.
  17.  
  18. Version 2.0 added the following new features:
  19.  
  20.      - Big batch files.
  21.      - A couple built-in commands to help lighten up on floppy disk I/O.
  22.      - Something that works well with TurboST's bugs.
  23.  
  24. -----------------------------------------------------------------------
  25.                               Batch Files
  26. -----------------------------------------------------------------------
  27.  
  28. Batch files are a series of command statements with optional  parameters 
  29. to be processed by the command.   Some commands are processed internally 
  30. by the monitor; anything that doesn't fall into the internal category is 
  31. assumed  to be a program command,  and it is Pexec'd.   Batch files  can 
  32. contain variables,  and the value of those variables can be supplied  at 
  33. runtime,  with  the batch monitor substituting the runtime text for  the 
  34. variable  symbols  as  they are encountered  in  the  batch  file.   The 
  35. commands  in the batch file are not case-sensitive.   The first word  on 
  36. each  line  (command  or  program name)  will  be  forced  to  uppercase 
  37. internally,  but  the rest of the command line (parms to passed  to  the 
  38. called  program)  are NOT changed in terms  of  case.   When  specifying 
  39. program names, a drive and path specification may be included as part of 
  40. the program name, if necessary.
  41.  
  42. -----------------------------------------------------------------------
  43.                            Internal Commands
  44. -----------------------------------------------------------------------
  45.  
  46. The batch monitor recognizes the following internal commands:
  47.  
  48.      COM
  49.      REM      -  These  commands are totally ignored,  allowing  you  to 
  50.                  insert  comments in your batch files.  In  addition  to 
  51.                  these,  any line starting with '!', '*', or ';' will be 
  52.                  considered  a  comment,  but the character MUST  be  in 
  53.                  column 1.
  54.  
  55.      DEL
  56.      DELETE   -  These commands delete 1-10 files,  as specified on  the 
  57.                  rest of the command line.
  58.                   Example:
  59.                     DEL     myfile1.txt myfile2.txt  
  60.                     DELETE  %1.tmp %1.obj
  61.      WAIT
  62.      PAUSE    -  These commands stop and wait for you to hit a key.  Any 
  63.                  parms on the line will be ignored,  so you can  include 
  64.                  comments on the line that pauses the run.
  65.  
  66.      RCSTOP
  67.      NORCSTOP -  These  commands turn on or off a flag which  will  stop 
  68.                  and prompt you if any program returns a non-zero return 
  69.                  code.   Some  compiler pieces are smart enough to  exit 
  70.                  with  a non-zero code if errors occurred.   Some  badly 
  71.                  written programs always (or randomly) return  non-zero.  
  72.                  You can use these codes to toggle the status on and off 
  73.                  around such programs.   When the batch montitor starts, 
  74.                  the default is RCSTOP.
  75.                   Example:
  76.                    NORCSTOP    Stupid 'badprog' always returns 1!
  77.                    BADPROG.PRG parm1 %1 %2 parm2
  78.                    RCSTOP      Resume RC checking.
  79.                  Note that parms are ignored, so you can put comments on 
  80.                  same line as the commands.
  81.  
  82.      SETENV   -  This  command allows access to the  environment  string 
  83.                  that will be passed to all called  programs.   Whatever 
  84.                  follows  the 'setenv' on the command line is passed  to 
  85.                  the  dLibs 'putenv()' function as is.   The  rules  for 
  86.                  'putenv' are as follows:
  87.                     <VARIABLE>
  88.                     <VARIABLE>=<string of characters>
  89.                  The  first  format (just a variable name)  will  remove 
  90.                  that variable from the current env string if it exists.  
  91.                  The  second  format allows you to set a variable  to  a 
  92.                  string.  
  93.                   Example:
  94.                     SETENV PATH=c:\bin\;a:\
  95.                     SETENV INCLUDE
  96.                  (I  have no idea whether this command  works.   If  the 
  97.                  dLibs  putenv() function works,  then this  should.   I 
  98.                  have no easy way of testing it, though.)
  99.  
  100.      EXEPATH  -  This  command  allows  you  to set  a  new  path  which 
  101.                  BATCHMON  will  use to find the programs  specified  in 
  102.                  the  rest of the batch file.   Note that this does  not 
  103.                  affect  the  DOS  default path;  any  programs  run  by 
  104.                  BATCHMON will inherit the current default path  (either 
  105.                  the path BATCHMON was run from,  or the path  specified 
  106.                  in  the  last 'DEFPATH'  command).   The  pathname  you 
  107.                  specify  for this command may include a drive,  and  it 
  108.                  may  end  with  a  '\'  character  or  not,   at   your 
  109.                  preference.
  110.                   Examples:
  111.                     EXEPATH c:\bin
  112.                     EXEPATH \sozobon\bin
  113.                     EXEPATH
  114.                  The  last example is equivelant to specifying  '\';  it 
  115.                  sets the path to the root of the current default drive.
  116.  
  117.      DEFPATH  -  This  command sets the DOS default  path.   Unless  you 
  118.                  have  used  the  EXEPATH  command,   this  will  affect 
  119.                  BATCHMON  (and where it will look for the programs  you 
  120.                  want run). It will always affect the programs called by 
  121.                  BATCHMON;   those   programs  will  also  inherit   the 
  122.                  specified default path.   If you specify a drive letter 
  123.                  as  part of the path,  that drive will become  the  new 
  124.                  default  drive.    You  may  specify  a  trailing   '\' 
  125.                  character or not, as you prefer.
  126.                   Examples:
  127.                     DEFPATH \data
  128.                     DEFPATH d:\source\
  129.                     DEFPATH
  130.                  The  last example is equivelant to specifying  '\';  it 
  131.                  sets the path to the root of the current default drive.
  132.  
  133. Internal commands (and indeed, anything) can be entered in upper, lower, 
  134. or  mixed  case in the batch file.   The first word on  each  line  (the 
  135. command or program name) is upper-cased by the program  internally,  and 
  136. the rest of the text and variables are left in the original case.   Note 
  137. that the desktop uppercases things typed into a .TTP dialog box.
  138.  
  139. -----------------------------------------------------------------------
  140.                                Variables
  141. -----------------------------------------------------------------------
  142.  
  143. Variables  in  the  batch file are %0  through  %9.   The  percent  sign 
  144. followed by a single digit will always be interpreted as a variable.   A 
  145. percent  sign  followed by anything else is not,  so you don't  have  to 
  146. double  up on percent signs to get a single one,  as with some  systems.  
  147. On the other hand,  there is no way to include the literal text "%1", it 
  148. will always be interpreted as a variable.  
  149.  
  150. The variable '%0' is a special case:   It is the name of the batch  file 
  151. that's running.   Note that it is the name that was passed to the  batch 
  152. monitor,  or  typed by the user,  and if it didn't have ".BAT" on it  at 
  153. that time,  it won't at substitution (even if the monitor had to tack on 
  154. a ".BAT" to open the file successfully,  this doesn't find its way  into 
  155. '%0').  I dunno if the '%0' variable will ever be useful to anyone,  but 
  156. it's a sort of freebie in the way the parser works).
  157.  
  158. The  variables '%1' through '%9' correspond to the first  through  ninth 
  159. words  you  passed  to the batch monitor at startup (or  typed  in  when 
  160. prompted).   By 'words' I mean groups of characters delimited by spaces.  
  161. I think it's about time for an example.   Suppose you have the following 
  162. batch file:
  163.  
  164.      COM      XMPL.BAT - A stupid example file.
  165.      compile  %1.c
  166.      asm      %2.s
  167.      link     newprog=startup %1.obj %2.o %3 
  168.  
  169. And then suppose you click on BATCHMON.TTP from the desktop,  and  enter 
  170. the  following in the dialog box (or you enter BATCHMON in  your  shell, 
  171. followed by these parms):
  172.  
  173.      xmpl cprog asmprog some,link,parms
  174.  
  175. Then the batch monitor would do the substitutions as follows:
  176.  
  177.      COM      XMPL.BAT - A stupid example file.
  178.      compile  cprog.c
  179.      asm      asmprog.s
  180.      link     newprog=startup cprog.obj asmprog.o some,link,parms
  181.  
  182. Notice that the commas weren't delimeters...to the batch monitor.   They 
  183. are to most linkers, and that can be handy.
  184.  
  185. If your batch file contains a '%3' variable (for example),  and you only 
  186. typed 2 parms at runtime,  you will see a warning message,  and the '%3' 
  187. will disappear.  (You will only be warned on the first occurance of each 
  188. non-existant variable.)  This lets you implement 'optional' variables in 
  189. your batch files.   In the above example,  if you didn't enter the third 
  190. parameter ('some,link,parms'), the last line would have substituted to:
  191.  
  192.      link     newprog=startup cprog.obj asmprog.o
  193.  
  194. The first word on a line in a batch file cannot be a variable (it  won't 
  195. get substituted);  that is, you can't execute a command or program via a 
  196. variable-supplied name.
  197.  
  198. -----------------------------------------------------------------------
  199.                              General Notes
  200. -----------------------------------------------------------------------
  201.  
  202. The  batch  monitor can be run as a .TOS or .TTP.   If you run  it  from 
  203. desktop as a .PRG you'll get ugly output.   You can run it from within a 
  204. shell,  if  the shell doesn't have a batch/script facility.   The  first 
  205. parm  you  pass to the BATCHMON program should be the name  of  a  batch 
  206. file, which usually ends in .BAT (it don't have to, but if you just pass 
  207. the  name  MYBATCH the program will  assume  MYBATCH.BAT).   The  second 
  208. through tenth parms (optional) correspond the the variables  %1-%9.   If 
  209. you don't pass any parms, the program will prompt you to enter the batch 
  210. filename and parms.
  211.  
  212. A  handy  way  to use the batch monitor is a method  which  doesn't  use 
  213. variables.   You  build  a custom .BAT file to compile  the  application 
  214. you're  working on (don't put any % variables in the  batch  file),  and 
  215. then install BATCHMON.TTP as an application on the desktop for file type 
  216. ".BAT".   Then,  when you double-click on "filename.BAT",  it'll fire up 
  217. the monitor and run the batch file.   Make sure the last command in  the 
  218. batch  file is a WAIT/PAUSE so you can view the output before  returning 
  219. to desktop.   If you're using this method, you can still run batch files 
  220. which use variables by clicking on BATCHMON.TTP and typing in the  batch 
  221. file name and parms.
  222.  
  223. To give the programs you're running in batch the appearance of commands, 
  224. it's not necessary to add the .PRG part of the program name.   The batch 
  225. monitor checks for a file type,  and if there is one,  fine;  if not, it 
  226. adds ".PRG".
  227.  
  228. When you are prompted for input (even single-char Y or N type), you will 
  229. have to hit <CR>.  No hotkey input for this kid!
  230.  
  231. The batch monitor does all it's console I/O with BIOS calls.   This  may 
  232. defeat  any I/O redirection you have in effect,  but it sure makes  life 
  233. easier if you have the fast-but-buggy TurboST software installed.   Good 
  234. ol' TurboST makes a lot of DOS console calls buggy.
  235.  
  236. This version of the monitor is a little bigger than the last one (almost 
  237. 10k!),  but it should only matter to a floppy disk user, who'll notice a 
  238. slightly longer load time.   The builtin wait and delete commands should 
  239. help a lot,  though.   Also,  I haven't checked but I'll bet the runtime 
  240. memory usage is about 15-17k,  I used lots of wasteful buffers (and now, 
  241. the wasteful dLibs runtime library).
  242.  
  243. This monitor was intended to emulate the one delivered with the original 
  244. ST  developer's package.   Not that that was a great batch monitor  that 
  245. deserves  emulation,  it's  just  that ALL my  batch  files  (litterally 
  246. hundreds) are set up for that.
  247.  
  248. -----------------------------------------------------------------------
  249.                 Notes about use with the Alcyon Compiler
  250. -----------------------------------------------------------------------
  251.  
  252. A typical batch file to compile the application FUNPROG might look  like 
  253. the following example (on my system, drive G is a ramdisk)...
  254.  
  255.      CP68         FUNPROG.C g:FUNPROG.I
  256.      C068       g:FUNPROG.I g:FUNPROG.1 g:FUNPROG.2 g:FUNPROG.3 -f
  257.      C168       g:FUNPROG.1 g:FUNPROG.2 g:FUNPROG.S
  258.      DELETE     g:FUNPROG.I g:FUNPROG.1 g:FUNPROG.2 
  259.      MAC        -6 -v -og:FUNPROG.o g:FUNPROG.s
  260.      DELETE     g:FUNPROG.S 
  261.      aln       -w -v -o FUNPROG.prg apstart.o g:FUNPROG.o libi.bnd 
  262.      DELETE     g:FUNPROG.O 
  263.      WAIT
  264.  
  265. A 'generic' batch file to compile a C application whose name is supplied 
  266. when the batch is started might look like...
  267.  
  268.      CP68         %1.C g:%1.I
  269.      C068       g:%1.I g:%1.1 g:%1.2 g:%1.3 -f
  270.      C168       g:%1.1 g:%1.2 g:%1.S
  271.      DELETE     g:%1.I g:%1.1 g:%1.2 
  272.      MAC        -6 -v -og:%1.o g:%1.s
  273.      DELETE     g:%1.S 
  274.      aln       -w -v -o %1.prg apstart.o g:%1 libi.bnd %2 %3 %4 %5
  275.      DELETE     g:%1.O 
  276.      WAIT
  277.  
  278. If  you  started BATCHMON and supplied the single  parameter  'FUNPROG', 
  279. this  batch file would run exactly like the previous  example.   If  you 
  280. supplied  the parameters as 'FUNPROG VDI.LIB AES.LIB',  the batch  would 
  281. run  like  the previous example except that your VDI and  AES  libraries 
  282. would be added to the linker's command line.  
  283.  
  284. -----------------------------------------------------------------------
  285.                 Notes for use with the Sozobon Compiler
  286. -----------------------------------------------------------------------
  287.  
  288. Sozobon  C  includes a 'cc' driver program which replaces the  need  for 
  289. batch  files,  if you are using a command shell.   Because some  of  the 
  290. compiler  pieces  recognize case-sensitive  switches,  it  is  virtually 
  291. impossible  to  run Sozobon C directly from the desktop (and  from  some 
  292. shells),  because all command line parms get forced to uppercase.  Using 
  293. BATCHMON in place of 'cc' allows you to get around these  problems,  and 
  294. allows  you to direct the intermediate files during the compiler  passes 
  295. to a ramdisk,  something which is not available when using 'cc'.   Also, 
  296. the  Sozobon  compiler pieces make certain assumptions about  the  paths 
  297. where things can be found,  and allow you to override these  assumptions 
  298. using envstring variables,  so BATCHMON includes support for setting env 
  299. strings.  The following examples again assume device G is a ramdisk...
  300.  
  301. If Sozobon has been installed exactly as described in it's docs...
  302.  
  303.      hcc     %1.c
  304.      top     %1.s g:%1.s
  305.      jas     -o g:%1.o g:%1.s
  306.      DEFPATH \sozobon\lib
  307.      ld      -o %1.prg dstart.o g:%1.o dlibs.a otherlib.a
  308.      DELETE  %1.s g:%1.s g:%1.o
  309.      WAIT
  310.  
  311. Notice that DEFPATH in that example was used before the linker,  so that 
  312. the  linker can find its input files in the location Sozobon  recommends 
  313. installing them. 
  314.  
  315. Here's  an example of one of my batch files,  in which I use  the  Atari 
  316. 'aln' linker as the final step to the Sozobon compiler...
  317.  
  318.      hcc     %1.c
  319.      top     %1.s g:%1.s
  320.      jas     -o g:%1.o g:%1.s
  321.      d:\aln  -o %1.prg apstart.o g:%1.o libi gemlib vdilib aeslib
  322.      DELETE  %1.s g:%1.s g:%1.o
  323.      WAIT
  324.  
  325. Note  that  the aln linker lives on a different drive than  the  Sozobon 
  326. stuff,  but  rather  than  changing the default or  EXE  paths,  I  just 
  327. explicitly  enter the full path to run for aln.   As a further  example, 
  328. when  I get a new release of Sozobon for testing,  I put it in  its  own 
  329. folder,  and  add  to  the start of the batch  file  the  line  'DEFPATH 
  330. F:\NEWSOZ'.
  331.  
  332. If you are installing Sozobon on a floppy disk system,  you may get some 
  333. performance  mileage  out  of the  following  concepts...  Put  all  the 
  334. executable  files in the root directory of the floppy disk,  along  with 
  335. the  big library files.   Put the most-used header files in  a  ramdisk, 
  336. leave  the rest on floppies,  and work your source in the ramdisk or  on 
  337. floppy  (whichever  feels  safer).   Your batch file  might  look  like: 
  338. (ramdisk is C)
  339.  
  340.      EXEPATH A:\
  341.      ! The following line will cause the source & intermediate
  342.      ! files to be worked on the ramdisk...
  343.      DEFPATH C:\
  344.      SETENV  INCLUDE=C:\;A:\
  345.      hcc     a:\%1.c
  346.      top     %1.s
  347.      jas     %1.s
  348.      ! Default path back to a:\ for link (lib files are on A).
  349.      DEFPATH A:\ 
  350.      ld      -o %1.prg dstart.o c:%1.o dlibs.a
  351.      WAIT
  352.           
  353. -----------------------------------------------------------------------
  354.                        Statement of Public Domain
  355. -----------------------------------------------------------------------
  356.  
  357. This  code  is  placed  into the  public  domain,  and  all  rights  and 
  358. copyrights to the code are waived.  Yep, you can abuse this beast in any 
  359. way  you see fit.   You can even include it as part of  your  commercial 
  360. application,  if  you are foolish enough to do so.   This code has  been 
  361. distributed  both independantly,  and as an adjunct to the Sozobon C  PD 
  362. compiler;  it does not carry the same copyright restrictions as the rest 
  363. of the Sozobon compiler, however.
  364.  
  365. I'll  be  happy to look at any bugs you discover,  if you can  get  your 
  366. comments  to me.   I can be reached on the national STadel  network  (as 
  367. 'Ian'), and on BIX as userid 'ianl'.
  368.  
  369.   Ian Lepore
  370.   11-05-88
  371.  
  372.